﻿using UnityEngine;
using System.Collections;
using ResourceSystem;

public class GameLaunch : MonoBehaviour
{

    // Use this for initialization
    void Start()
    {

        ResourceSystemFacade.Inst.InitSystem(false);
        UISystemFacade.Inst.InitSystem();
        UISystemFacade.Inst.OpenWindow(1);


        GameCenter.Inst.BehaviorSystemFacade.Init(GameCenter.Inst.BehaviorContext);
        BehaviorEntity entity= GameCenter.Inst.BehaviorContext.CreateEntity();
        NodeComponent node = new NodeComponent();
        node.RootData = new SingleBranchNodeData();
        node.RootData.CurNodeState = BehaviorNodeState.Running;
        node.RootData.CurNodeType = BehaviorNodeType.EnterNode;
        MultiBranchNodeData squenceNode = new MultiBranchNodeData();
        squenceNode.CurNodeState = BehaviorNodeState.Running;
        squenceNode.CurNodeType = BehaviorNodeType.SequenceNode;

        LeafNodeData waitNode = new LeafNodeData();
        waitNode.CurNodeState = BehaviorNodeState.Running;
        waitNode.CurNodeType = BehaviorNodeType.WaitNode;

        NumTaskData numData = new NumTaskData();
        numData.TargetNum = 5;
        waitNode.TaskArgs = numData; 
        squenceNode.ChildNodes.Add(waitNode);
        node.RootData.ChildNode = squenceNode;
        entity.Components.Add(ComponentType.NodeComponent,node);

        LitJson.JsonData data =ResourceSystemFacade.Inst.ReadJson("D:/WorkSpace/Demos/gitee/StarLightFramework/Project/StarLightFramework/Assets/StreamingAssets/Config/HeroBehavior.json");
        DebugUtils.LogRedInfo(data.ToJson());
       NodeData node2 = (NodeData)GameCenter.Inst.BehaviorSystemFacade.SerializeNodeData(data.ToJson());
        DebugUtils.LogRedInfo(((SingleBranchNodeData)node2));
    }

    // Update is called once per frame
    void Update()
    {
        GameCenter.Inst.BehaviorSystemFacade.Excute();
    }
}
